package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"pets/models"
)

type TypesController struct {
	beego.Controller
}

func (c *TypesController) Add() {
	name := c.GetString("name")
	types := c.GetString("types")
	userid, _ := c.GetInt("userid")
	pets := models.PetTypes{
		Name:   name,
		Types:  types,
		Userid: userid,
	}
	models.DB.Debug().Create(&pets)
	c.Data["json"] = Res{
		Code:     200,
		Data:     nil,
		Database: "添加成功",
	}
	c.ServeJSON()
	return
}
